home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13474 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: lrz-muenchen.de!news
  2. From: watzka@stat.uni-muenchen.de (Kurt Watzka)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: malloc question
  5. Date: 7 Apr 1996 08:59:45 GMT
  6. Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
  7. Distribution: world
  8. Message-ID: <4k8061$l5@sparcserver.lrz-muenchen.de>
  9. References: <4k6tgn$13c8@pulp.ucs.ualberta.ca>
  10. NNTP-Posting-Host: sun2.lrz-muenchen.de
  11.  
  12. hcolquho@gpu3.srv.ualberta.ca (Harry Colquhoun) writes:
  13.  
  14. >Not quite sure what's happening here, most likely something real stupid I 
  15. >did, I'm sure.
  16.  
  17. >compiled using djgpp under MSDOS->works fine
  18. >compiled using djgpp on SGI->core dump 
  19.  
  20. >-------------------------
  21. >global variable 'frames'
  22.  
  23. >the problem:
  24.  
  25. >unsigned long int *mem;
  26. >mem = (unsigned long int *) malloc (frames);
  27. >-------------------------
  28.  
  29. >changing to 'unsigned long int mem[100]' and no malloc fixes problem
  30.  
  31.  
  32. >Anyone know why?
  33.  
  34. Because "works fine" is a DOS expression for "does not diagnose a
  35. horrible error". 
  36.  
  37. Try:
  38.  
  39.   mem = malloc(frames * sizeof(*mem));
  40.  
  41. Kurt
  42. --
  43. | Kurt Watzka                             Phone : +49-89-2180-6254
  44. | watzka@stat.uni-muenchen.de
  45.